package utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.apache.log4j.Logger;

public class hl95 {
	static Logger logger = Logger.getLogger(hl95.class);
	
	private static String url;
	private static String response;
	
	public static long send(String msg,String phone) throws UnsupportedEncodingException{
		String codestr=URLEncoder.encode(msg,"GBK");
		String linkid=phone+GenerateRandNumHelper.generate(3);
		url="http://114.255.71.158:8061/?username=fzkd002" +
				"&password=fzkd002" +
				"&message=" +codestr+
				"&phone=" +phone+
				"&epid=109655" +
				"&linkid=" +linkid+
				"&subcode=";
		response=GetHelper.doHttpGet(url);
//		System.out.println(" hl response: "+response);
//		System.out.println("url: "+url);
		if(response.trim().equals("00")){
			return Long.parseLong(linkid);
		}else{
			//短信发送失败
			logger.info("[Error]hl95 send fail response: "+response);
			return -1;
		}
		
	}
	
	public static void main(String[] args) {
		try {
			send("晚上好。 ！","13559455537");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
